<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('毛利润报表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<style>
    select {
        padding-top: 3px !important;
    }

    .select-list {
        margin-top: 5px !important;
    }

    .select-list li p {
        width: auto !important;
        margin-top: 7px !important;
    }
</style>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">

        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="project-form">
                    <div class="col-sm-12">


                        <div class="select-list">
                            <ul>
                                <li>
                                    <p>工程公司：</p>
                                    <select id="compId" name="compId" class="form-control noselect2">
                                        <option value="">请选择</option>
                                        <option th:each="pro:${userComp}"
                                                th:value="${pro.compId}"
                                                th:text="${pro.compName}"></option>
                                    </select>


                                </li>
                                <li>
                                    <p>项目名称：</p>

                                    <select class="form-control noselect2" id="proName" name="proName">
                                        <option value="">请选择</option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="searchValue();"><i
                                            class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="resetValue();"><i
                                            class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </form>
            </div>
            <from id="ordinary-form">
                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">计划毛利(万元)</h4>
                    <table id="plangorssprofit"></table>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">实际毛利(万元)</h4>
                    <table id="actualgorssprofit"></table>
                </div>
            </from>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var prefix = ctx + "grossProfit";
    var prefixs = ctx + "outPutValue";
    var compId;
    var html;
    var value;
    var planoption;
    var actualoption;
    $(function () {
        $("#compId").change(function () {
            compId = $("#compId option:selected").val();
            $.ajax({
                url: prefixs + '/findProByCompId',
                data: {
                    "compId": compId
                },
                success: function (data) {
                    $("#proName").find("option").remove();
                    $("#proName").append('<option value="">请选择</option>');
                    // if ($("#compId option:selected").val() == "") {
                    //     $("#proName").append('<option value="">请选择</option>')
                    // }
                    for (var i in data.data) {
                        html = data.data[i].pro_name;
                        value = data.data[i].comp_id;
                        $("#proName").append('<option value="' + html + '">' + html + '</option>')
                    }
                }
            })
        });
        var planoptions = {
            url: prefix + '/findPlanList',
            id: "plangorssprofit",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                field: 'compName',
                title: '工程公司'
            }, {
                field: 'pro_name',
                title: '项目名称'
            }, {
                field: 'gcPerson',
                title: '工程负责人'
            }, {
                field: 'swPerson',
                title: '商务负责人'
            },
                {
                    field: 'contractAmount',
                    title: '合同额'
                },
                {
                    field: 'profitMargin',
                    title: '利润率'
                }
                , {
                    field: 'january',
                    title: '一月'
                }, {
                    field: 'february',
                    title: '二月'
                }, {
                    field: 'march',
                    title: '三月'
                }, {
                    field: 'april',
                    title: '四月'
                }, {
                    field: 'may',
                    title: '五月'
                }, {
                    field: 'june',
                    title: '六月'
                }, {
                    field: 'july',
                    title: '七月'
                }, {
                    field: 'august',
                    title: '八月'
                }, {
                    field: 'september',
                    title: '九月'
                }, {
                    field: 'october',
                    title: '十月'
                }, {
                    field: 'november',
                    title: '十一月'
                }, {
                    field: 'december',
                    title: '十二月'
                }, {
                    field: 'total',
                    title: '合计(万元)'
                }]
        };
        $.table.init(planoptions);

        var actualoptions = {
            url: prefix + '/findActualList',
            id: "actualgorssprofit",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                field: 'compName',
                title: '工程公司'
            }, {
                field: 'pro_name',
                title: '项目名称'
            }, {
                field: 'gcPerson',
                title: '工程负责人'
            }, {
                field: 'swPerson',
                title: '商务负责人'
            },
                {
                    field: 'contractAmount',
                    title: '合同额'
                },
                {
                    field: 'profitMargin',
                    title: '利润率'
                },
                {
                    field: 'january',
                    title: '一月'
                }, {
                    field: 'february',
                    title: '二月'
                }, {
                    field: 'march',
                    title: '三月'
                }, {
                    field: 'april',
                    title: '四月'
                }, {
                    field: 'may',
                    title: '五月'
                }, {
                    field: 'june',
                    title: '六月'
                }, {
                    field: 'july',
                    title: '七月'
                }, {
                    field: 'august',
                    title: '八月'
                }, {
                    field: 'september',
                    title: '九月'
                }, {
                    field: 'october',
                    title: '十月'
                }, {
                    field: 'november',
                    title: '十一月'
                }, {
                    field: 'december',
                    title: '十二月'
                }, {
                    field: 'total',
                    title: '合计(万元)'
                }]
        };
        $.table.init(actualoptions);
        planoption = planoptions;
        actualoption = actualoptions;
    })

    function searchValue() {
        $("#plangorssprofit").bootstrapTable('refresh', planoption);
        $("#actualgorssprofit").bootstrapTable('refresh', actualoption);
    }

    function resetValue() {
        $.form.reset();
        $("#plangorssprofit").bootstrapTable('refresh');
        $("#actualgorssprofit").bootstrapTable('refresh');
    }
</script>
</body>

</html>